package com.sdx.console.system.service;

import com.ibeetl.admin.core.service.BaseService;
import com.ibeetl.admin.core.util.PlatformException;
import com.sdx.console.system.dao.ChannelSetDao;
import com.sdx.console.system.entity.ChannelSet;
import org.beetl.sql.core.engine.PageQuery;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

/**
 * 渠道 Service
 */

@Service
@Transactional
public class ChannelSetService extends BaseService<ChannelSet>{

    @Resource
	private ChannelSetDao channelSetDao;

    public PageQuery<ChannelSet>queryByCondition(PageQuery query){
        PageQuery ret =  channelSetDao.queryByCondition(query);
        queryListAfter(ret.getList());
        return ret;
    }

    public void batchDelChannelSet(List<String> ids){
        try {
            channelSetDao.batchDelChannelSetByIds(ids);
        } catch (Exception e) {
            throw new PlatformException("批量删除渠道失败", e);
        }
    }

	public List<ChannelSet> selectAuthChannels(Integer dataAccessType,Long orgId,Integer tenantId) {
    	return channelSetDao.selectAuthChannels(dataAccessType, orgId, tenantId);
	}

	public List<ChannelSet> selectAuthCodeChannels(Integer dataAccessType,Long orgId,Integer tenantId) {
		return channelSetDao.selectAuthCodeChannels(dataAccessType, orgId,tenantId);
	}

	public List<ChannelSet> all() {
		return channelSetDao.all();
		}

    public List<ChannelSet> selectChannelSet(Long orgId) {
        return channelSetDao.selectChannelSet(orgId);
    }
}